<template>
  <div>
    <home-header :city="city"></home-header>
    <home-swiper :list="swiperList"></home-swiper>
    <home-icons :list="iconList"></home-icons>
    <home-weekend :list="weekendList"></home-weekend>
    <home-recommend :list="recommend"></home-recommend>
  </div>
</template>
<script>
  import HomeHeader from './commponents/Header'
  import HomeSwiper from './commponents/Swiper'
  import HomeIcons from './commponents/Icons'
  import HomeRecommend from './commponents/Recommend'
  import HomeWeekend from './commponents/Weekend'
  import axios from 'axios'

  export default {
    name: 'Home',
    components: {
      HomeHeader: HomeHeader,
      HomeSwiper: HomeSwiper,
      HomeIcons: HomeIcons,
      HomeRecommend: HomeRecommend,
      HomeWeekend: HomeWeekend
    },
    data () {
      return {
        city: '',
        swiperList: [],
        iconList: [],
        recommend: [],
        weekendList: []
      }
    },
    methods: {
      getHomeInfo () {
        axios.get('/api/index.json')
          .then(this.getHomeInfoSucc)
      },
      getHomeInfoSucc (res) {
        res = res.data
        if (res.ret && res.data) {
          const data = res.data
          this.city = data.city
          this.swiperList = data.swiperList
          this.iconList = data.iconList
          this.recommend = data.recommendList
          this.weekendList = data.weekendList
        }
      }
    },
    mounted () {
      this.getHomeInfo()
    }
  }
</script>
<style>

</style>
